﻿using Common.AspNetCore.Structs;
using Common.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Common.AspNetCore
{
    [Route("api/SysApi")]
    public class SysApiController : SysApiControllerBase
    {
        public SysApiController(IServiceProvider provider)
             : base(provider)
        {
        }

        [HttpPost, Route("GetIdModel")]
        public ApiActionResult<object> GetIdModel([FromBody] ModelIdRequest modelRequest)
        {
            return DoGetIdModel(modelRequest);
        }

        [HttpPost, Route("GetModel")]
        public ApiActionResult<object> GetModel([FromBody] ModelRequest modelRequest)
        {
            return DoGetModel(modelRequest);
        }

        [HttpPost, Route("GetOrderModel")]
        public ApiActionResult<object> GetOrderModel([FromBody] ModelRequest modelRequest)
        {
            return DoGetOrderModel(modelRequest);
        }

        [HttpPost, Route("GetOrderPageModel")]
        public ApiActionResult<object> GetOrderPageModel([FromBody] ModelOrderPageRequest modelRequest)
        {
            return DoGetOrderPageModel(modelRequest);
        }

        [HttpPost, Route("GetEntityIds")]
        public ApiActionResult<List<string>> GetEntityIds([FromBody] IDParam idModel)
        {
            return DoGetEntityIds(idModel);
        }

        [HttpPost, Route("DatabaseMigrate")]
        public ApiActionResult<bool> DatabaseMigrate([FromBody] DatabaseMigrateParam migrateParam)
        {
            return DoDatabaseMigrate(migrateParam);
        }

        [HttpPost, Route("SaveModel")]
        public async Task<ApiActionResult<bool>> SaveModel([FromBody] ModelSaveRequest request)
        {
            return await DoSaveModel(request);
        }

        [HttpPost, Route("DeleteModel")]
        public async Task<ApiActionResult<bool>> DeleteModel([FromBody] ModelDeleteRequest request)
        {
            return await DoDeleteModel(request);
        }
    }
}
